package com.example.jikeyoujikeyou.office_sz.view.activity;

import android.app.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.example.jikeyoujikeyou.office_sz.R;



/**
 * Created by sziit on 2017/12/27.
 */


public class ForgetActivity extends BaseActivity {


    private Button btn;

    private Button Nextbtn;

    private TimeCount timeCount;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.forget_the_password);

        btn = (Button) findViewById(R.id.button);

        Nextbtn = (Button) findViewById(R.id.button3);

        timeCount = new TimeCount(10000, 1000,btn);



        //下一步按钮点击监听下一步按钮点击监听
        Nextbtn.setOnClickListener(new View.OnClickListener() {


            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(ForgetActivity.this,modifyActivity.class);
                ForgetActivity.this.startActivity(intent);
            }
        });

        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                timeCount.start();
            }

        });
    }

    //获取按钮点击监听
    class TimeCount extends CountDownTimer {
        private Button btn;
        public TimeCount(long millisInFuture, long countDownInterval,Button bt) {
            super(millisInFuture, countDownInterval);
            btn = bt;
        }

        public void onFinish() {
            btn.setText("获取验证码");
            btn.setClickable(true);
            btn.setSelected(false);

        }

        public void onTick(long millisUntilFinished) {
            btn.setClickable(false);
            btn.setSelected(true);
            int mill = (int)millisUntilFinished / 1000;
            if( mill > 1){
                btn.setText(millisUntilFinished / 1000 + "s");
                return;
            }
            btn.setText("重新获取");
        }
    }
    }


